package ma.co.ba.BusinessApplications.business.activites.impl;

import java.util.List;

import ma.co.ba.BusinessApplications.business.activites.ActiviteBusiness;
import ma.co.ba.BusinessApplications.dao.commons.DAOServices;
import ma.co.ba.BusinessApplications.model.Activite;
import ma.co.ba.BusinessApplications.model.Utilisateur;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("activiteBusiness")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class ActiviteBusinessImpl implements ActiviteBusiness {

	@Autowired
	DAOServices daoServices;

	public List<Activite> getAllActivites() {
		return (List<Activite>) daoServices.getEntities(Activite.class);
	}

	public List<Activite> getAllActivitesByUser(String userName) {
		Utilisateur user = (Utilisateur) daoServices
				.getUniqueEntitiyByProperty(Utilisateur.class, "nomComplet",
						userName);

		System.out.println(user.getActivites());
		return (List<Activite>) user.getActivites();
	}

	public List<Activite> getAllActivitesByUserAndEtat(String userName,
			boolean validation, boolean active) {
		System.out.println("this activite business function return null");
		return null;
	}

	public List<Activite> getAllActivitesByEtat(boolean validation) {
		System.out.println("this activite business function return null");
		return null;
	}

}
